package com.itheima.threadatom3;

import java.util.concurrent.atomic.AtomicInteger;

public class AtomIntegerDemo2 {
    public static void main(String[] args) {
        AtomicInteger ai1 = new AtomicInteger(10);
        int i = ai1.get();
        System.out.println(i);

        AtomicInteger ai2 = new AtomicInteger(10);
        int i2 = ai2.getAndIncrement();
        System.out.println(i2);
        System.out.println(ai2.get());

        AtomicInteger ai3 = new AtomicInteger(10);
        int i3 = ai3.incrementAndGet();
        System.out.println(i3);

        AtomicInteger ai4 = new AtomicInteger(10);
        int add = ai4.getAndAdd(15);
        System.out.println(add);
        System.out.println(ai4.get());

        AtomicInteger ai5 = new AtomicInteger(10);
        int add2 = ai5.addAndGet(20);
        System.out.println(add2);
        System.out.println(ai5.get());

        AtomicInteger ai6 = new AtomicInteger(10);
        int newValue = ai6.getAndSet(33);
        System.out.println(newValue);
        System.out.println(ai6.get());

        AtomicInteger ai7 = new AtomicInteger(10);
        ai7.set(35);
        System.out.println(ai7.get());
    }
}
